package openadmin.model.person;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import openadmin.dao.Base;
import openadmin.model.territory.Address;
import openadmin.model.territory.Municipality;
import openadmin.model.territory.TypeStreet;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@Table(name = "reside", schema = "person", uniqueConstraints = @UniqueConstraint(columnNames="description"))
public class Reside implements Base, java.io.Serializable{

	/** attribute that contains the identifier*/
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)	
	private Integer id;
	
	/** attribute that contains the description, unique value*/
	@Length(max = 15)
	@NotNull
	private String description;

	/** attribute that contains the relationship with Municipality*/
	@ManyToOne
	@JoinColumn(name = "municipality", nullable= false)
	private Municipality municipality;
	
	/** attribute that contains the post code */
	private Integer postcode;
	
	/** attribute that contains the post office box */
	private Integer postofficebox;
	
	/** attribute that contains the relationship with Address, if this is 0 then isn't structural address*/
	@ManyToOne
	@JoinColumn(name = "address", nullable = false)
	private Address address;
	
	/** attribute that contains the relationship with type of Street*/
	@ManyToOne
	@JoinColumn(name = "typestreet", nullable= false)
	private TypeStreet typestreet;
	
	@Length(max = 40)	
	private String registeredaddress;
	
	private boolean notice;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date begindate;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date Dateend;
	
	/** Transient attribute that means that the system should make a log on any JPA operation of this class*/
	@Transient
	boolean debuglog = true;
	
	/** Transient attribute that means that the system should make a historic on any JPA operation of this class*/
	@Transient
	boolean historiclog = false;

	public Reside() {
		
		super();
		
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Municipality getMunicipality() {
		return municipality;
	}

	public void setMunicipality(Municipality municipality) {
		this.municipality = municipality;
	}

	public Integer getPostcode() {
		return postcode;
	}

	public void setPostcode(Integer postcode) {
		this.postcode = postcode;
	}

	public Integer getPostofficebox() {
		return postofficebox;
	}

	public void setPostofficebox(Integer postofficebox) {
		this.postofficebox = postofficebox;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public TypeStreet getTypestreet() {
		return typestreet;
	}

	public void setTypestreet(TypeStreet typestreet) {
		this.typestreet = typestreet;
	}

	public String getRegisteredaddress() {
		return registeredaddress;
	}

	public void setRegisteredaddress(String registeredaddress) {
		this.registeredaddress = registeredaddress;
	}

	public boolean isNotice() {
		return notice;
	}

	public void setNotice(boolean notice) {
		this.notice = notice;
	}

	public Date getBegindate() {
		return begindate;
	}

	public void setBegindate(Date begindate) {
		this.begindate = begindate;
	}

	public Date getDateend() {
		return Dateend;
	}

	public void setDateend(Date dateend) {
		Dateend = dateend;
	}

	public boolean getDebugLog() {
		return debuglog;
	}

	public void setDebuglog(boolean debuglog) {
		this.debuglog = debuglog;
	}
	
	public boolean getHistoricLog() {
		return historiclog;
	}

	public void setHistoricLog(boolean historiclog) {
		this.historiclog = historiclog;
	}
	
	@Override
	public String toString(){
		 
		 return description;
	}
	
	
}
